<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateTeamAwardsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('team_awards', function (Blueprint $table) {
            $table->id();
            $table->integer('store_id')->unsigned()->default(0)->comment('店铺id');
            $table->tinyInteger('min_level')->unsigned()->default(0)->comment('可获取团队奖励I的最小会员等级 默认为0');
            $table->tinyInteger('division_num')->unsigned()->default(0)->comment('N级数目 , 计算分界线');
            $table->string('radio_inner')->default('')->comment('N级以内的各级比例 {“1”:0.01 , "2":0.02 , "3":0.03} ');
            $table->decimal('radio_outer', 8, 2)->default(0)->comment('N级以外的统一比例 最长三位 , 最多保留两位小数');
            $table->integer('rela_num')->unsigned()->default(0)->comment('N级以外最多分配的代数');
            $table->tinyInteger('n_inner')->unsigned()->default(1)->comment('设置N级外分配的军功章为订单金额的几倍  只支持整数');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `team_awards` comment '店铺团队奖励规则表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('team_awards');
    }
}
